package com.chat.http.service;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;
import com.chat.dao.ChatPeopleRelationDao;
/**
 * td_chat_people_relation表操作service层
 * @author zh_zhong
 *
 */
@Service("peopleRelationService")
public class PeopleRelationService {
	
	@Autowired
	private ChatPeopleRelationDao peopleRelationDao;
	
	
	//判断是否好友关系
	public boolean isFriend(String fromUserName, String toUserName){
		
		String friendsStr = peopleRelationDao.getAllFriendByUserName(fromUserName);
		
		if (friendsStr == null){
			return false;
		}
		
		String[] friendsArr = friendsStr.split(",");
		if (friendsArr == null){
			
			System.out.println("friendsArr is null");
			
			return false;
		}
		
		for (String friend : friendsArr){
			if (toUserName.equals(friend))
				return true;
		}
		
		return false;
	}

}
